package com.marco.ipdata.listener;

import com.marco.commons.SpringContextUtils;
import com.marco.ipdata.service.impl.BaiduApiServiceImpl;
import com.marco.ipdata.service.impl.GaodeApiServiceImpl;
import com.marco.ipdata.service.impl.SinaApiServiceImpl;
import com.marco.ipdata.service.impl.TaobaoApiServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * IPDataProcessListener.java
 * Create on 2017/3/23
 * Copyright(c) JD Inc 2017. All Rights Reserved.
 * <pre>
 * 功能说明：
 * </pre>
 */
public class IPDataProcessListener implements ServletContextListener {
    private static final Logger logger = LoggerFactory.getLogger(IPDataProcessListener.class);

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        logger.info("---------处理IP接口调用监听器开启中--------------");
//        final TaobaoApiServiceImpl taobaoApiService = (TaobaoApiServiceImpl) SpringContextUtils.getBeanById
//                ("taobaoApiServiceImpl");
//        //开启线程调用淘宝接口及处理数据
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                taobaoApiService.obtainApiDataByParam();
//                taobaoApiService.process();
//            }
//        }).start();
//
//        //开启线程调用百度接口及处理数据
//        final BaiduApiServiceImpl baiduApiService = (BaiduApiServiceImpl) SpringContextUtils.getBeanById("baiduApiServiceImpl");
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                baiduApiService.obtainApiDataByParam();
//                baiduApiService.process();
//            }
//        }).start();
//
//        //开启线程调用新浪接口及处理数据
//        final SinaApiServiceImpl sinaApiService = (SinaApiServiceImpl) SpringContextUtils.getBeanById
//                ("sinaApiServiceImpl");
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                sinaApiService.obtainApiDataByParam();
//                sinaApiService.process();
//            }
//        }).start();
//
//        //开启线程调用高德接口及处理数据
//        final GaodeApiServiceImpl gaodeApiService = (GaodeApiServiceImpl) SpringContextUtils.getBeanById
//                ("gaodeApiServiceImpl");
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                gaodeApiService.obtainApiDataByParam();
//                gaodeApiService.process();
//            }
//        }).start();
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
    }
}
